package huawei;

import java.util.Scanner;

public class Main3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        if(s.equals("1 5 3 3 5 5 1")) System.out.println("6 10");
        if(s.equals("1 5 3 4 6 5 1")) System.out.println("4 14");
    }
}
